package cn.liweixi._03_oneway;

import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.client.producer.SendCallback;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.remoting.common.RemotingHelper;


public class producer {
    public static void main(String[] args) throws Exception {
        //创建一个生产者对象
        DefaultMQProducer producer = new DefaultMQProducer("hahah-oneway");
        //连接nameserver
        producer.setNamesrvAddr("127.0.0.1:9876");
        //开启
        producer.start();
        //发送消息
        Message msg = new Message("topic-oneway", "tag-oneway", "陈圆圆".getBytes(RemotingHelper.DEFAULT_CHARSET));
        producer.sendOneway(msg);
        //关闭，异步请求的话可能不会等到发送成功就进行关闭了，所以就需要注释
        producer.shutdown();

    }
}
